package cn.jaye.fabric.application;

import cn.jaye.fabric.application.command.TestCommand;
import cn.jaye.fabric.common.constant.Global;
import cn.jaye.fabric.domain.service.RestTemplateService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Jaye
 * @create 2018-05-31 15:20
 */
@Service
public class TestApplication {
    @Autowired
    private RestTemplateService restTemplateService;


    private static final String TEST = "/block/info";


    public JSONObject list(TestCommand testCommand) {
        String url = Global.FABRRIC_GATEWAY_ADDRESS + TEST;
        JSONObject postData = new JSONObject();
        postData.put("channelName",testCommand.getChannelName());
        postData.put("dataHash","ec2a42a1f71d968a57fbbca22e1dd2c08df168aa5c5ed6d32bf24aab28c43223");
        JSONObject resultObject = restTemplateService.getUrlResponse(url, postData);
        System.out.println(resultObject.getString("data"));
        return resultObject;
    }
}
